package com.mrx.commons.task.model;

import com.mrx.commons.task.logger.ITaskLogger;
import lombok.Data;
import lombok.RequiredArgsConstructor;

import java.lang.reflect.Method;

/**
 * @author Mr.X
 * @since 2024-01-12 16:31
 **/
@Data
@RequiredArgsConstructor(staticName = "of")
public class XTask {
    private final TaskCreateVO vo;
    private final Method mainMethod;
    private final ITaskLogger logger;

    public void collectStackTrace(Throwable t) {
        if (logger != null) {
            logger.printStackTrace(t);
        }
    }

    public String getLog() {
        return logger == null ? null : logger.get();
    }
}
